package com.example.youhuo.z_a_onepage

import android.app.Dialog
import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.example.myapplication.R
import com.example.youhuo.utils.Custom_Dialog
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class Splash_dialog(context: Context): Dialog(context){
    var customDialog: Custom_Dialog? = null
    var agreeclick: agreeOnClick? = null
    var disagreeclick: disagreeOnClick? = null

    fun create_Dialog() {
        var custom_dialog = LayoutInflater.from(context).inflate(R.layout.antivity_main_splash, null)
        customDialog = Custom_Dialog(context)
        var go = custom_dialog.findViewById<ImageView>(R.id.splash_go)
        var delete = custom_dialog.findViewById<ImageView>(R.id.splash_delete)

        //展示dialog
        customDialog!!.addContentView(
            custom_dialog, LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT
            )
        )
        customDialog!!.window!!.setBackgroundDrawable(ColorDrawable(0))
        customDialog!!.show()

//        文字的点击
        go.setOnClickListener(View.OnClickListener {

            customDialog!!.dismiss()

//            agreeclick!!.agreeOnClickListener()

        })
        delete.setOnClickListener(View.OnClickListener {
//            disagreeclick!!.disagreeOnClickListener()
            customDialog!!.dismiss()
        })



    }
    fun getagreeOnClick(agreeOnClick: agreeOnClick) {
        this.agreeclick = agreeOnClick
    }

    fun getdisagreeOnClick(disagreeOnClick: disagreeOnClick) {
        this.disagreeclick = disagreeOnClick
    }

    //接口回调
    interface agreeOnClick {
        fun agreeOnClickListener()
    }

    interface disagreeOnClick {
        fun disagreeOnClickListener()
    }
}